﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
using System.Security.Cryptography;
using System.Configuration;

namespace LIMS.Entities
{
    public class Resource
    {
        //Paths
        public const string MAIL_CONFIG_FILE = "Mail.config";
        public const string MAIL_USER_REGISTRATION_TO_ADMIN_TEMPLATE = "MailTemplates\\UserRegistrationAdmin.htm";
        public const string MAIL_USER_REGISTRATION_TO_USER_TEMPLATE = "MailTemplates\\UserRegistrationUser.htm";
        public const string MAIL_PASSWORD_RESET_TEMPLATE = "MailTemplates\\PasswordReset.htm";

        public const string MAIL_CUSTOMER_LESS_CREDIT_TEMPLATE = "MailTemplates\\CustomerLessCreditLimit.htm";
        public const string MAIL_THANKS_FOR_ORDER = "MailTemplates\\ThanksForOrder.htm";
        public const string MAIL_ORDER_UNDER_PROCESS = "MailTemplates\\OrderUnderProcess.htm";
        public const string MAIL_GOODS_DISPATCHED = "MailTemplates\\GoodsDispatched.htm";
        public const string MAIL_ORDER_CANCELLED = "MailTemplates\\OrderCancelled.htm";
        public const string MAIL_ORDER_DELIVERED = "MailTemplates\\OrderDelivered.htm";
        public const string MAIL_CUSTOMER_REGISTRATION = "MailTemplates\\CustomerRegistration.htm";
        public const string MAIL_OVERDUE_INVOICE = "MailTemplates\\OverDueInvoice.htm";
        public const int ADMIN_GROUP_DB_ID = 1;

        //Session related
        public const string SESSION_VAR_LOGGED_IN_USER = "LoggedInUserId";
        public const string SESSION_VAR_LOGGED_IN_USER_DB_ID = "LoggedInDBId";
        public const string SESSION_VAR_SESSION_ID = "Id";
        public const string SESSION_VAR_IS_USER_LOGGED = "IsUserLoggedIn";
        public const string SESSION_VAL_USER_LOGGED_YES = "Yes";
        public const string SESSION_VAL_USER_LOGGED_NO = "No";
        public const string SESSION_VAR_USER_FULL_NAME = "LoggedInUserFullName";
        public const string SESSION_VAR_USER_SITE_ID = "LoggedInUserSiteId";
        public const string SESSION_VAR_USER_SITE_Name = "LoggedInUserSiteName";

        public const string SESSION_VAR_USER_PERMISSION_TYPES = "LoggedInUserPermissionTypes";
        public const string SESSION_IMPORT_FILE_TASK_ID = "ImportFileTaskId";
        public const string IMPORT_LOG_FILE_PATH = "LogFilePath";
        public const string IMPORT_LOG_FILE = "LogFileName";
        public const string IMPORT_FILE_NAME = "ImportFileName";
        //public const  SESSION_VAR_USER_PERMISSION_TYPE = "LoggedInUserPermissionType";
        public const string SESSION_VAR_RETURN_URL = "ReturnUrl";
        public const string SESSION_VAR_GRID_PAGE_SIZE = "GridPageSize";
        //Navigation between pages
        public const string SESSION_IS_CUSTOMER_NAVIGATE = "IsCustomerNavigate";
        public const string SESSION_ORDER_BUNDLE = "OrderBundle";

        public const string SESSION_IS_CUSTOMER_NAVIGATE_TO_ORDER = "IsCustomerNavigateToOrder";
        public const string SESSION_CUSTOMER_ID_OF_CUSTOMER = "IsCustomerIdofCustomer";

        public const string SESSION_IS_NAVIGATE_FROM_ORDER = "IsNavigateFromOrder";
        public const string SESSION_ORDER_ID_OF_ORDER = "NavigateOrderId";

        //For Invoices
        public const string SESSION_IS_NAVIGATE_FROM_ORDER_INVOICES = "IsNavigateFromOrderInvoice";
        public const string SESSION_ORDER_ID_OF_ORDER_INVOICES = "NavigateOrderInvoiceId";

        //For Delivery
        public const string SESSION_IS_NAVIGATE_FROM_ORDER_DELIVERY = "IsNavigateFromOrderDelivery";
        public const string SESSION_ORDER_ID_OF_ORDER_DELIVERY = "NavigateOrderDeliveryId";
        //Navigate from delivery
        public const string SESSION_IS_NAVIGATE_FROM_DELIVERY = "IsNavigateFromDelivery";

        //Navigate from invoice
        public const string SESSION_IS_NAVIGATE_FROM_INVOICES = "IsNavigateFromInvoice";


        //Create Invoice for Delivery
        public const string SESSION_DELIVERY_DETAILS_FOR_CREATE_INVOICE = "DeliveryDetailsForInvoiceCreation";
        public const string SESSION_IS_INVOICE_LIMS_DELIVERY = "CreateInvoiceByDelivery";

        //Is customer navigate from payment
        public const string SESSION_INVOICE_ID_NAVIGATE_FROM_PAYMENT = "IsNavigateFromPayment";
        public const string SESSION_CUSOTMER_ID_BACK_TO_PAYMENT = "IsBackToPayment";

        //Product options
        public const string SESSION_SELECT_PRODUCT_OPTIONS = "SelectedProductOptions";
        public const string SESSION_SELECTED_OPTIONS = "SelectedOptions";
        //Order lines
        public const string SESSION_SAVED_ORDER_LINES = "OrderLinesInititally";

        //Credit note
        //from Invoice page
        public const string SESSION_INVOICE_ID_FOR_CREDIT_NOTE = "InvoiceIdForCreditNote";
        public const string SESSION_CREDIT_NOTE_INVOICE_ID = "CreditNoteInvoiceId";
        //from customer page
        public const string SESSION_CUSTOMER_ID_FOR_CREDIT_NOTE = "CustomerIdForCreditNote";
        public const string SESSION_CREDIT_NOTE_CUSTOMER_ID = "CreditNoteCustomerId";
        //Pages

        public const string SESSION_HOME_PAGE = "CAMPHomePage";
        public const string PAGE_ADMINISTRATION = "Administration.aspx";
        public const string PAGE_LOGIN = "/Default.aspx";
        public const string PAGE_LOGIN_CLIENT = "/Default.aspx";
        public const string PAGE_USER_HOME = "/HomePage.aspx";
        public const string PAGE_REGISTER = "/UserRegistration.aspx";

        public const string CUSTOMER_REGISTER = "/NewUserRegistration.aspx";
        public const string PAGE_ORDER_PROFILE = "/CustomerOrdersProfile.aspx";


        public const string PAGE_USER_MANAGEMENT = "/UserManagement.aspx";
        public const string PAGE_GROUP_MANAGEMENT = "/GroupManagement.aspx";
        public const string PAGE_SITE_MANAGEMENT = "/SiteManagement.aspx";
        public const string PAGE_CUSTOMER_GROUP_MANAGEMENT = "/CustomerGroupsManagement.aspx";
        public const string PAGE_CUSTOMER_TYPE_MANAGEMENT = "/CustomerTypesManagement.aspx";

        public const string PAGE_CUSTOMER_MANAGEMENT = "/CustomerManagement.aspx";
        public const string PAGE_IMPORT_PRODUCTS = "/ImportProducts.aspx";
        public const string PAGE_PRODUCT_MANAGEMENT = "/ProductManagement.aspx";


        public const string PAGE_ORDER_MANAGEMENT = "/CustomerOrderManagement.aspx";
        public const string PAGE_INVOICE_MANAGEMENT = "/InvoiceManagement.aspx";
        public const string PAGE_DELIVERY_MANAGEMENT = "/DeliveryManagement.aspx";

        public const string PAGE_DELIVERY_CHARGE_MANAGEMENT = "/DeliveryChargeManagement.aspx";
        public const string PAGE_VAT_MANAGEMENT = "/VatManagement.aspx";
        public const string PAGE_DOCUMENT_AREA = "/DocumentManagement.aspx";
        public const string PAGE_CREDIT_NOTE_MANAGEMENT = "/CreditNoteManagement.aspx";
        public const string PAGE_MACHINE_MANAGEMENT = "/MachineManagement.aspx";
        public const string PAGE_DOWNLOAD = "/Download.aspx";

        //Reports
        public const string PAGE_QUITE_CUSTOMER_REPORTS = "/QuiteCustomerReports.aspx";
        public const string PAGE_INVOICE_REPORTS = "/InvoiceReports.aspx";
        public const string PAGE_CUSTOMER_GROUP_INVOICE = "/CustomerGroupInvoice.aspx";
        public const string PAGE_OVERDUE_REPORT = "/OverDueReport.aspx";
        public const string PAGE_PAYMENTDETAILS_REPORT = "/PaymentDetailsReports.aspx";
        public const string PAGE_CUSTOMERORDER_REPORT = "/CustomerOrderReport.aspx";
        public const string PAGE_ORDER_DELIVERY_REPORT = "/OrderDeliveryReport.aspx";
        public const string PAGE_CUSTOMER_ORDERS_REPORT = "/CustomerOrdersReport.aspx";
        public const string PAGE_CUSTOMER_INVOICES_REPORT = "/CustomerInvoicesReport.aspx";      
        public const string PAGE_MACHINE_STOCK_REPORT = "/MachineStockReport.aspx";
        public const string PAGE_DETAILED_MACHINE_STOCK_REPORT = "/DetailedMachineStockReport.aspx";
        public const string PAGE_PROFIT_REPORT = "/ProfitReport.aspx";
        public const string PAGE_SPECIAL_PRICE_REPORT = "/SpecialPriceReport.aspx";
        public const string PAGE_YEARLY_INVOICE_AMOUNT_REPORT = "/YearlyInvoiceAmountReports.aspx";
        public const string PAGE_CREDIT_LIMIT_PAYMENT_TERM_REPORT = "/CreditLimitPaymentTermReport.aspx";
        
        //Error massages
        public const string ERROR_NAME_INVALID = "Name is invalid. Please enter valid value";
        public const string ERROR_VALUE_INVALID = "Value is invalid. Please enter valid value";
        public const string ERROR_VALUE_NOT_NUMERIC = "Value is not numeric. Please enter valid value";
        public const string ERROR_DESCRIPTION_INVALID = "Description is invalid. Please enter valid value";
        public const string ERROR_DISPLAY_ORDER_INVALID = "Display order is invalid. Please enter valid value";
        public const string ERROR_DISPLAY_ORDER_NOT_NUMERIC = "Display order is not numeric. Please enter valid value";



        public const string DDL_DEFAULT_VALUE = "-Select-";
        public const string DDL_ALL_VALUE = "All";
        public const string DDL_ACTIVE_VALUE = "Active";
        public const string DDL_DRAFT_STATUS = "Draft";
        public const string DEFAULT_TEXT = "Default";
        public const string DEFAULT_NUMBER = "0";
        public const string BUTTON_UPDATE_TEXT = "Update";
        public const string BUTTON_SAVE_TEXT = "Save";
        public const string BUTTON_EDIT_TEXT = "Edit";
        public const string BUTTON_VIEW_TEXT = "View";
        public const string BUTTON_RECORD_DELIVERY_TEXT = "Record Delivery";
        public const string BUTTON_TRANSFER_TEXT = "Transfer";
        public const string BUTTON_ACCEPT_TEXT = "Accept";
        public const string BUTTON_RETURN_TEXT = "Return";

        public const string EXCEL_EXPORT_FILE_NAME = ".\\ExcelFileFolder\\ImportFile_";
        public const string MACHINE_NOTES_FILE_NAME = ".\\MachineNotes";
        public const string IMPORT_LOG_FILE_NAME = ".\\ExcelFileFolder\\ImportLogFolder\\LogFile_";
        public const string EXCEL_EXPORT_FILE_NAME_FOR_TREAD = ".\\ExcelFileFolder\\";
        public const string IMPORT_LOG_FILE_NAME_FOR_TREAD = ".\\ExcelFileFolder\\ImportLogFolder\\";
        //UI MESSAGES
        public const string UI_MESSAGE_UPDATE_SUCCESS = "Update successful";
        public const string UI_MESSAGE_DELETE_SUCCESS = "Delete successful";
        public const string UI_MESSAGE_CREATE_SUCCESS = "New record created successfully";
        public const string UI_MESSAGE_SPECIAL_PRICE_ADDED = "Special price added successfully";
        public const string UI_MESSAGE_PASSWORD_RESET_REQUEST_SUCCESS = "Password reset request sent successfully to registered Email address.";
        public const string UI_MESSAGE_PASSWORD_RESET_SUCCESS = "Password reset successfully.";
        public const string UI_MESSAGE_NO_RECORD_FOUND = "No records found.";
        public const string UI_MESSAGE_CANNOT_DELETE = "Record is already deleted.";
        public const string UI_MESSAGE_REGISTER_USER_SUCCESS = "New user created successfully, you'll soon get intimation about your account activation in your registered Email address.";
        public const string SAVE_PRODUCT_LINE_BEFORE_SAVING_RECORD = "Save product line before saving record.";
        public const string CANNOT_CREATE_ORDER_PENDING_INVOICES = "Order cannot be created because overdue invoices exists for this customer.";

        //UI ERROR

        public const string UI_ERROR_CREATE_FAIL = "Error occured while creating record. Please refer to error logs.";
        public const string UI_ERROR_SAVE_FAIL = "Error occured while saving record. Please refer to error logs.";
        public const string UI_ERROR_DELETE_FAIL = "Error occured while deleting record. Please refer to error logs.";
        public const string UI_ERROR_INIT_FAIL = "Error occured while initilizing. Please refer to error logs.";
        public const string UI_ERROR_UPDATE_FAIL = "Error occured while updating record. Please refer to error logs.";
        public const string UI_ERROR_OCCURED = "Error occured. Please refer to error logs.";
        public const string UI_ERROR_DELETE_PASS_INIT_FAIL = "Deleting was successful but initialization failed. Please refer to error logs.";
        public const string UI_ERROR_SAVE_PASS_INIT_FAIL = "Addition was successful but initialization failed. Please refer to error logs.";
        public const string UI_ERROR_PASSWORD_RESET_FAIL = "Password reset failed, plase contact administrator.";
        public const string UI_ERROR_USER_REGISTRATION_FAIL = "Registration failed, please contact administrator.";
        public const string UI_DEFAULT_VAT_ERROR = "Default vat cannot be deleted.";
        public const string UI_DEFAULT_DELIVERY_CHARGE_ERROR = "Default delivery charge cannot be deleted.";

        //CSS CLASSES

        public const string CSS_NONE = "none";
        public const string CSS_LABEL_INFO = "message";
        public const string CSS_LABEL_ERROR = "errmsg";
        public const string CSS_LABEL_MESSAGE = "message";
        public const string CSS_BUTTON_DISABLE = "button-primary";
        public const string CSS_BUTTON_PRIMARY = "button-primary"; //Need to change



        //User management page, validation messages.
        public const string ERROR_USER_NAME_EMPTY = "User name cannot be empty";
        public const string ERROR_USER_NAME_DUPLICATE = "User name already exists in system, please select another name";
        public const string ERROR_CANT_SHIFT_CUSTOMER = "Customer group cannot be unassigned.";
        public const string ERROR_BRANCH_NAME_DUPLICATE = "Branch name already exists in system, please select another name.";
        public const string ERROR_VAT_CODE_DUPLICATE = "Vat code already exists in system, please select another code.";
        public const string ERROR_COUNTRY_NAME_DUPLICATE = "Country name already exists in system, please select another name";
        public const string ERROR_GROUP_NAME_DUPLICATE = "Group name already exists in system, please select another name";
        public const string ERROR_EMAIL_DUPLICATE = "Email address already exists in system, please select another";
        public const string ERROR_MACHINE_DUPLICATE = "Machine already exists in system with this model and serial number, please enter another serial number";
        public const string ERROR_USER_FIRST_NAME_EMPTY = "User first name cannot be empty";
        public const string ERROR_USER_LAST_NAME_EMPTY = "User last name cannot be empty";
        public const string ERROR_PASSWORD_EMPTY = "Password cannot be empty";
        public const string ERROR_PASSWORD_NO_MATCH = "Passwords do not match";
        public const string ERROR_DESIGNATION_EMPTY = "Designation cannot be empty";
        public const string ERROR_EMAIL_EMPTY = "Email cannot be empty";
        public const string ERROR_EMAIL_FORMAT = "Email format is incorrect.";
        public const string ERROR_STATUS = "Please select a status.";
        public const string ERROR_COUNTRY = "Please select a country.";
        public const string ERROR_STATE = "Please select a state.";
        public const string ERROR_ACTION = "Please select an action";

        public const string ERROR_EMPTY_FIELD = " cannot be empty.";
        public const string ERROR_ALPHA_NUMERIC = " required alpha-numeric value.";
        public const string ERROR_PHONE = " Phone formet is not correct.";
        public const string ERROR_ZIPCODE = " Zip code formet is not correct.";
        public const string ERROR_MANDATORY = " is mandatory.";
        public const string ERROR_NUMERIC = " required numeric value.";
        public const string ERROR_SELECT_VALUE = "Please select ";

        public const string ERROR_LENGTH = " cannot be greater then ";
        public const string ERROR_IP_ADDRESS = " IP address is not in correct format.";
        public const string DAILY = "DAILY";
        public const string MONTHLY = "MONTHLY";
        public const string CUSTOMER_ASSOCIATED = "1";
        public const string CUSTOMER_NOT_ASSOCIATED = "0";
        public const string CUSTOMER_ASSOCIATION_DELETED = "2";

        public const string STATUS_IN_PROGRESS = "P";
        // product 
        public const string ERROR_PRODUCT_CODE_DUPLICATE = "Product code already exists in system, please select another code";
        public const string ERROR_PRODUCT_CATEGORY_NAME_DUPLICATE = "Product category already exists in system, please select another name";
        public const string ERROR_PRODUCT_CODE_EXPORT = "Some Errors in exporting excel file, please check the log file.";
        public const string PRODUCT_EXPORT_SUCCESS = "Excel file uploaded successfully";
        public const string ERROR_NOT_EXCEL_FILE = "Please select an Excel file for Product Import, it should be Office 2007 format (.xlsx extension).";
        public const string ERROR_NOT_NOTES_FILE = "Please select a JPG or PDF file for Import.";
        //Search in Product         
        public const string ACTIVE_STATUS = "A";
        public const string DELETED_STATUS = "D";
        public const string ORDER_COMPLETED = "O";
        public const string ORDER_CANCELLED = "C";
        public const string ORDER_DRAFT = "U";
        public const string UI_MESSAGE_ORDER_CANT_SAVE_AS_DRAFT = "Cannot set status to draft as deliveries exist for this order.";
        public const string UI_MESSAGE_ORDER_CANT_SAVE_AS_DELETED = "Cannot set status to delete as signed deliveries exist for this order.";
        public const string UI_MESSAGE_ORDER_DELETE_NOTE = "Enter a note if you want to delete this order and its associated deliveries.";
        public const string UI_MESSAGE_ORDER_CANCELLED_NOTE = "Enter a note if you want to cancel this order and its associated deliveries.";
        public const string UI_MESSAGE_ORDER_CANT_SAVE_AS_CANCELLED = "Cannot set status to cancel as signed deliveries exist for this order.";
        public const string UI_ERROR_ORDER_COMPLETED = "Cannot set status to completed.";
        public const string UI_ERROR_CHANGE_ORDER = "Cannot change order as signed deliveries exist for this order.";
        public const string UI_MESSAGE_DELIVERY_DELETE_NOTE = "Enter a note if you want to delete this delivery.";
        // Label Name
        public const string BRANCH_NAME = "Branch name ";
        public const string ADDRESS = "Address ";
        public const string ZIP_CODE = "Zip Code ";
        public const string TELEPHONE = "TelePhone ";
        public const string FAX = "Fax ";
        public const string EMAIL = "Email ";
        public const string IP_ADDRESS = "IP Address ";
        public const string INVOICE_SERIES = "Invoice Series ";
        public const string ORDER_SERIES = "Order Series ";
        public const string INVOICE_PREFIX = "Invoice Prefix ";
        public const string ORDER_PREFIX = "Order Prefix ";
        public const string STATUS = "Status ";

        public const string VAT_CODE = "Vat code ";
        public const string VAT_DESCRIPTION = "Vat Description ";
        public const string VAT_VALUE = "Vat value ";

        //Customer 
        public const string ERROR_CUSTOMER_CODE_DUPLICATE = "Customer Code already exists, please select another Code.";
        public const string ERROR_CUSTOMER_NAME_DUPLICATE = "Customer Name already exists, please select another Name.";
        public const string ERROR_CUSTOMER_SAVED_PAYMENT_NOT_SAVED = "Customer saved or updated, but error in saving payment.";
        public const string ERROR_NO_PAYMENT_FOUND = "No payment records found.";
        public const string SEARCH_CUSTOMER_BY_NAME = "NAME";
        public const string SEARCH_CUSTOMER_BY_ACCOUNT_NUMBER = "ACCOUNT NUMBER";
        //Customer Group
        public const string ERROR_CUSTOMER_GROUP_CODE_DUPLICATE = "Customer Group Code already exists in system, please enter any other code.";
        public const string ERROR_CUSTOMER_GROUP_NAME_DUPLICATE = "Customer Group Name already exists in system, please enter any other name.";
        //Customer Type
        public const string ERROR_CUSTOMER_TYPE_DUPLICATE = "Customer Type already exists in system, please enter any other type.";

        //Customer Discount Type
        public const string ERROR_CUSTOMER_DISCOUNT_TYPE_DUPLICATE = "Customer Discount Type already exists in system, please enter any other type.";
        //In User Management for Customer 
        public const string IS_CUSTOMER = "CUSTOMER";
        //Order
        public const string SEARCH_ORDER_BY_NUMBER = "ORDER NUMBER";
        public const string SEARCH_ORDER_BY_CUSTOMER_NAME = "CUSTOMER NAME";
        public const string ERROR_ORDER_NUMBER_DUPLICATE = "This Order Number is already in use. Please enter a new Order Number.";
        public const string CHECKED_ITEMS = "Check Box Checks";
        public const string CANT_BE_ZERO = " can't be zero or blank";
        public const string CANT_BE_ALFA_NUMERIC = "Only numeric value allowed ";
        public const string CANT_BE_CHARACTER = " can't be alphabets.";
        public const string OrderPrefix = "OrderPrefix";
        public const string OrderSeries = "OrderSeries";
        public const string NO_PRODUCT_SELECTED_FOR_ORDER = "No product is selected, please select products for order.";
        public const string CUSTOMER_TYPE_IS_DEALER = "Dealer";
        public const string PLEASE_CHANGE_PRICE_TO_CURRENCY = "Please change the price of the product before selecting it";
        public const string PRODUCT_IS_ALREADY_IN_LIST = "Selected product is already in selected products list.";
        public const string DELIVERY_METHOD_COLLECTION = "Collection";
        public const string DELIVERY_METHOD_LOCAL_DELIVERY = "Local Delivery";
        public const string DELIVERY_METHOD_COURIER = "Courier";
        //Delivery
        public const string ERROR_DELIVERY_CHARGE_CODE_DUPLICATE = "Delivery Charge code already exists in system, please enter any other code.";
        //Import Products
        public const string YES_DELETED = "Y";
        public const string HEADING_CATEGORY = "CATEGORY";
        public const string HEADING_SUBCATEGORY = "SUB CATEGORY";
        public const string HEADING_MANUFACTURER = "SUPPLIER";
        public const string HEADING_CODE = "CODE";
        public const string HEADING_PRODUCT_DESCRIPTION = "PRODUCT DESCRIPTION";
        public const string HEADING_WE_PAY = "WE PAY";
        public const string HEADING_DEALER_PRICE = "DEALER PRICE";
        public const string HEADING_LIST_PRICE = "LIST PRICE";
        public const string HEADING_END_USER_PRICE = "END USER PRICE";
        public const string HEADING_DELETED = "DELETED?";
        public const string HEADING_OPTIONS = "OPTIONS";
        public const string HEADING_PRICEBREAKUP = "PRICE BREAK";
        public const string PRODUCT_IMPORT_CODE = "Product Code (";
        public const string PRODUCT_CAN_NOT_IMPORT = ") cannot be imported because ";
        public const string USER_PRICE_NOT_RECOGNIZE = "End user price not recognize. Please check the end user price.";
        public const string INVALID_TEMPLETE_FORMAT = "Import failed: Format of Excel file is not valid.";
        public const string EMPTY_ROW_FOUND = "Row is empty.\n";
        // Delivery
        public const string ERROR_DELIVERY_NUMBER_DUPLICATE = "Delivery Number already exists in system, please enter correct number.";
        //Cash Payment Types

        public const string PAYMENT_INVOICE = "Invoice";
        public const string PAYMENT_PAID_IN_SHOP = "Paid in shop";
        public const string PAYMENT_PAY_ON_DELIVERY = "Pay on delivery";
        public const string PAYMENT_TELEVISA = "Televisa";

        // Invoice
        public const string ERROR_INVOICE_NUMBER_DUPLICATE = "Invoice Number already exists in system, please enter other number.";
        public const string InvoicePrefix = "InvoicePrefix";
        public const string InvoiceSeries = "InvoiceSeries";
        public const string NO_ORDER_FOUND_FOR_INVOICE = "No order found for invoice or invoice is being created.";
        //Report All Sites
        public const string REPORT_ALL_SITES = "--All--";
        public const string REPORT_START_DATE = "01-01-1900";
        public const string REPORT_END_DATE = "01-01-2100";

        //Order, Delivery and Invoice Matching
        //For Order Invoice status
        public const string STATUS_DELIVER_NOT_DELIVERED = "ND";
        public const string STATUS_DELIVER_ACTIVE = "A";
        public const string STATUS_DELIVER_PART_DELIVERED = "PD";
        public const string STATUS_DELIVER_FULL_DELIVERED = "FD";
        //For order delivery status
        public const string STATUS_INVOICE_NOT_INVOICED = "NI";
        public const string STATUS_INVOICE_PART_INVOICED = "PI";
        public const string STATUS_INVOICE_FULL_INVOICED = "FI";
        //For Order Lines
        public const string STATUS_NOT_DELIVERED = "N";
        public const string STATUS_PART_DELIVERED = "P";
        public const string STATUS_FULL_DELIVERED = "F";
        //Invoice Paid Status
        public const string STATUS_INVOICE_NOT_PAID = "NP";
        public const string STATUS_INVOICE_FULL_PAID = "FP";
        //public const string STATUS_INVOICE_CREDIT_NOTE = "CN";
        //Invoice credit note status types
        public const string STATUS_INVOICE_NO_CREDIT_NOTE = "NC";
        public const string STATUS_INVOICE_PART_CREDIT_NOTE = "PC";
        public const string STATUS_INVOICE_FULL_CREDIT_NOTE = "FC";        
        //Super user check
        public const string SUPER_USER_NAME = "superimre";
        public const string SUPER_USER_PASSWORD = "1956";
        //Details
        public const string SUPER_USER_FULL_NAME = "Imre Super User";
        public const string SUPER_USER_SITE_ID = "1";
        public const string SUPER_USER_DB_ID = "-7";
        //Credit Notes
        public const string CREDIT_NOTE_STATUS_ACTIVE = "A";
        public const string CREDIT_NOTE_STATUS_REDEEMED = "R";
        public const string NO_ITEM_REMAIN_FOR_CREDIT_NOTE = "Credit notes are already raised, No item remaining for credit note.";
        public const string CREDIT_NOTE_TRANSFR_TO_ACCOUNT = "Account";
        public const string CREDIT_NOTE_PAYMENT_TYPE_VALUE = "CN";
        public const string CREDIT_NOTE_PAYMENT_TYPE_TEXT = "Credit Note";
        public const string CREDIT_NOTE_CREATED = "Credit note created";
        public const string CREDIT_NOTE_REDEEM = "Credit note redeemed";
        public const string CREDIT_NOTE_CREATED_NOT_PAID = "Credit note created for not paid invoice";

        //Group Management
        public const string MESSAGE_NO_RIGHTS_FOR_CUSTOMER = "Assigning this permission will not assign any rights in the current version of the system.(Future implementation)";

        //Machine Stock
        public const string MACHINE_GLOSSOP_ROAD_MACHINES = "G";
        public const string MACHINE_AREA_LOAN_MACHINES = "L";
        public const string MACHINE_AREA_SOLD_MACHINES = "S";
        public const string MACHINE_AREA_LOAN_MACHINES_FULL = "Loan Machines";
        public const string MACHINE_AREA_SOLD_MACHINES_FULL = "Sold Machines";

        //Mail scheduling 
        public const string MAIL_SCHEDULE_ENTITY_TYPE_INVOICE = "I";
        public const string ERROR_TRANSFER_NOT_POSIBLE = "Transfer not possible because both (source and destination) area are same.";


        //LiMS Site
        public const string CANNOT_DELETE = " cannot be deleted since it has dependency";
        public const string MANUFACTURER_SAVED_SUCCESSFULLY = "Manufacturer saved successfully.";
        public const string SUPPLIER_SAVED_SUCCESSFULLY = "Supplier saved successfully.";


        //LIMS Site Status
        public static Dictionary<string, string> StatusTypes = new Dictionary<string, string>()
        {
           
            {"A","Active"},
            {"D","Deactive"}
           
        };

        /// <summary>
        /// Status Types of order for delivery
        /// </summary>
        public static Dictionary<string, string> OrderDeliveryStatusTypes = new Dictionary<string, string>()
        {                       
            {"A","Active"},    
            {"D","Deleted"},    
            {"ND","Not Delivered"},
            {"PD","Part Delivered"},
            {"FD","Fully Delivered"}               
        };
        /// <summary>
        /// Status Types of order for invoice
        /// </summary>
        public static Dictionary<string, string> OrderInvoiceStatusTypes = new Dictionary<string, string>()
        {            
            {"NI","Not Invoice"},    
            {"PI","Part Invoice"},    
            {"FI","Fully Invoice"}             
        };
        public static Dictionary<string, string> InvoicePaidStatusTypes = new Dictionary<string, string>()
        {            
            {"NP","Not Paid"},               
            {"FP","Fully Paid"}
           // {"CN","Credit Note"}
        };
        public static Dictionary<string, string> CNStatusTypes = new Dictionary<string, string>()
        {            
            {"A","Active"},               
            {"R","Redeemed"}             
        };
        /// <summary>
        /// order for an order
        /// </summary>
        public static Dictionary<string, string> OrderStatusTypes = new Dictionary<string, string>()
        {
            {"U","Draft"},
            {"A","Active"},
            {"C","Cancelled"},
            {"D","Deleted"},            
            {"O","Completed"}        
        };
        /// <summary>
        /// Get Order Line Status Types
        /// </summary>
        public static Dictionary<string, string> OrderLineStatusTypes = new Dictionary<string, string>()
        {                     
            {"N","Not Delivered"},
            {"P","Part Delivered"},
            {"F","Fully Delivered"}                 
        };

        public static Dictionary<string, string> PermissionTypes = new Dictionary<string, string>()
        {
            {"U","User Management"},
            {"G","Group Management"},
            {"S","Site Management"},
            {"T","Customer Type Management"},
            {"H","Customer Groups Management"},
            {"Z","VAT management"},
            {"L","Delivery Charge Management"},           
            {"C","Customer Management"},
            {"V","Customer Management (View Only)" },
            {"3","Customer Management (Non Editable)" },
            {"E","Import Products"},
            {"P","Product Management"},
            {"O","Order Management"},
            {"D","Delivery Management"},
            {"I","Invoice Management"},
            {"A","Document Area"},     
            {"F","Machine Management"},     
            {"1","Credit Notes" },
            {"Q","Quiet Customer Reports"},
            {"M","Invoice Reports"},
            {"N","Customer Group Invoice Reports" },
            {"W","Overdue Report" },
            {"X","Payment Details Report" },                       
            {"Y","Customer Order Report" },
            {"B","Overview Report"},
            {"J","Machine Stock Report" },
            {"R","Profit Report" },
            {"2","Special Price Report" },            
            {"4","Yearly Report" },
            {"K","Customer" }
           //Used Words - A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z, 1,2,3,4            
        };

        public static Dictionary<string, string> ParentCategoryType = new Dictionary<string, string>()
        {
            {"P","Parent"},
            {"SC","Sub-Category"}
            
        };
        public static Dictionary<string, string> OfferPrices = new Dictionary<string, string>()
        {
            {"99999.00","Special Price"},
            {"77777.00","Please Ring"}           
        };
        public static Dictionary<string, string> PaymentTypes = new Dictionary<string, string>()
        {
            {"I","Cash"},
            {"S","Bacs"},
            {"D","Cheque"},
            {"T","Televisa"},
            {"CN","Credit Note"}
        };
        public static Dictionary<string, string> PaymentMethodForOrder = new Dictionary<string, string>()
        {
            {"I","Invoice"},
            {"S","Cash"},
            {"D","Card"},
            {"C","Cheque"}     
            //Can't naming correctly because data is already on server.

        };
        public static Dictionary<string, string> PaymentTerms = new Dictionary<string, string>()
        {
            {"0","0 Days Payment Upfront"},
            {"30","30 Days"},
            {"42","42 Days"},            
            {"60","60 Days"}            
        };
        public static Dictionary<string, string> CutOffPaymentTerms = new Dictionary<string, string>()
        {
            {"0","0 Days Payment Upfront"},
            {"30","30 Days"},
            {"42","42 Days"},            
            {"60","60 Days"},
            {"75","75 Days"}        
        };
        public static Dictionary<string, string> DeliveryMethod = new Dictionary<string, string>()
        {            
            {"C","Courier"},          
            {"L","Local Delivery"},
            {"O","Collection"}                     
        };
        public static Dictionary<string, string> MachineStockAreas = new Dictionary<string, string>()
        {
            {"G","Glossop Road"},
            {"F","Factory"},
            {"C","Chesterfield"},
            {"L","Loan Machines"},
            {"S","Sold Machines"}
        };
        public static Dictionary<string, string> QuiteCustomerWeeks = new Dictionary<string, string>()
        {
            {"14","2 Weeks"},
            {"28","4 Weeks"},
            {"56","8 Weeks"},
            {"84","12 Weeks"}
        };

        public static Dictionary<int, string> UserTypeDic = new Dictionary<int, string>()
        {
            {0,"--Select--"},
            {1,"Head of department"},
            {2,"Manager"},
            {3,"Supervisor"},
            {4,"User"}
        };

        public static Dictionary<string, string> UserStatusDic = new Dictionary<string, string>()
        {
            {"X","--Select--"},
            {"A","Active"},
            {"I","In progress"}
        };

        public static Dictionary<string, string> StatusDic = new Dictionary<string, string>()
        {
            {"X","--Select--"},
            {"A","Active"},
            {"D","Deactive"}
        };

        public static List<Status> BindStatus()
        {
            List<Status> oResultList = new List<Status>();
            
            Status oNewStatus = new Status();
            oNewStatus.StatusKey = "X";
            oNewStatus.StatusValue = "--Select--";
            oResultList.Add(oNewStatus);

            oNewStatus = new Status();
            oNewStatus.StatusKey = "A";
            oNewStatus.StatusValue = "Active";
            oResultList.Add(oNewStatus);

            oNewStatus = new Status();
            oNewStatus.StatusKey = "D";
            oNewStatus.StatusValue = "Deactive";
            oResultList.Add(oNewStatus);

            return oResultList;

        }

        //Methods

        /// <summary>
        /// 
        /// </summary>
        /// <param name="inputEmail"></param>
        /// <returns></returns>
        public static bool IsValidEmail(string inputEmail)
        {
            string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                  @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                  @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
            Regex re = new Regex(strRegex);
            if (re.IsMatch(inputEmail))
                return (true);
            else
                return (false);
        }
        //Method to Check the given string is integer or not
        public static bool IsNumeric(string strVal)
        {
            Regex reg = new Regex("[^0-9-]");
            Regex reg2 = new Regex("^-[0-9]+$|^[0-9]+$");
            return (!reg.IsMatch(strVal) && reg2.IsMatch(strVal));
        }
        //Method to Check the given string is alpha numeric or not
        private static bool IsAlphaNumeric(string str)
        {
            return Regex.Match(str.Trim(), @"^[a-zA-Z0-9]*$").Success;
        }
        // Method to Check the given string is float or not
        public static bool IsFloat(string strVal)
        {
            double dFloat;
            if (!double.TryParse(strVal, out dFloat))
            {
                return false;
            }
            return true;

        }
        public static int GetGridPageSize()
        {
            int iPageSize = 10;
            try
            {
                int iParsePageSize = 0;
                string sReadPageSize = ConfigurationSettings.AppSettings["NumberofRecordsInGrid"];
                if (sReadPageSize != null)
                {
                    if (int.TryParse(sReadPageSize, out iParsePageSize))
                    {
                        iPageSize = iParsePageSize;
                        return iPageSize;
                    }
                    else
                    {
                        return iPageSize;
                    }
                }
                else
                {
                    return iPageSize;
                }

            }
            catch (Exception)
            {
                return iPageSize;
            }
        }


        /// <summary>
        /// method to validate an IP address
        /// using regular expressions. The pattern
        /// being used will validate an ip address
        /// with the range of 1.0.0.0 to 255.255.255.255
        /// </summary>
        /// <param name="addr">Address to validate</param>
        /// <returns></returns>
        public static bool IsValidIP(string addr)
        {
            //create our match pattern
            string pattern = @"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";
            //create our Regular Expression object
            Regex check = new Regex(pattern);
            //boolean variable to hold the status
            bool valid = false;
            //check to make sure an ip address was provided
            if (addr == "")
            {
                //no address provided so return false
                valid = false;
            }
            else
            {
                //address provided so use the IsMatch Method
                //of the Regular Expression object
                valid = check.IsMatch(addr, 0);
            }
            //return the results
            return valid;
        }

        //Method to Check UK Phone NUmber
        public static bool IsUKPhoneNumber(string strVal)
        {
            string strRegex = @"^\d{4}\d{3}\d{4}$";
            Regex re = new Regex(strRegex);
            if (!re.IsMatch(strVal))
                return (true);
            else
                return (false);
        }
        //Method to Check UK ZIP Code
        public static bool IsUKZIPCode(string strVal)
        {
            string strRegex = @"^?(([BEGLMNSWbeglmnsw][0-9][0-9]?)|(([A-PR-UWYZa-pr-uwyz][A-HK-Ya-hk-y][0-9][0-9]?)|(([ENWenw][0-9][A-HJKSTUWa-hjkstuw])|([ENWenw][A-HK-Ya-hk-y][0-9][ABEHMNPRVWXYabehmnprvwxy])))) ?[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}$";
            Regex re = new Regex(strRegex);
            if (re.IsMatch(strVal))
                return (true);
            else
                return (false);
        }
        //Check for URL
        public static bool IsValidUrl(string strVal)
        {
            string pattern = @"(http://|)(www\.)?([^\.]+)\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$";
            Regex objAlphaPattern = new Regex(pattern);
            if (objAlphaPattern.IsMatch(strVal))
                return (true);
            else
                return (false);
        }
        /// <summary>
        /// Gets all states for status list which are haed coded in enums
        /// </summary>
        /// <returns></returns>
        public static List<string> GetStatusStates()
        {
            List<string> stateList = new List<string>();
            stateList.Add(DDL_DEFAULT_VALUE);

            foreach (StatusTypes state in Enum.GetValues(typeof(StatusTypes)))
                stateList.Add(state.ToString());
            return stateList;
        }

        /// <summary>
        /// Gets all permission actions which are hardcoaded in enums
        /// </summary>
        /// <returns></returns>
        public static List<string> GetPermissionActions()
        {
            List<string> stateList = new List<string>();
            stateList.Add(DDL_DEFAULT_VALUE);

            foreach (PermissionTypes state in Enum.GetValues(typeof(PermissionTypes)))
                stateList.Add(state.ToString());
            return stateList;
        }

        public static List<string> GetStringCompareDataSource()
        {
            List<string> list = new List<string>();
            list.Add("Contains");
            list.Add("Equals");
            list.Add("Starts with");
            list.Add("Ends with");
            return list;
        }
        /// <summary>
        /// Gets status list LIMS SITE
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCodedStatusList()
        {
            List<string> statusList = new List<string>();
            statusList.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.StatusTypes)
                statusList.Add(oKP.Value);
            return statusList;
        }
        public static List<KeyNames> GetBindingListFromDictionary(Dictionary<string, string> oDictionary)
        {
            try
            {
                List<KeyNames> oReturnList = new List<KeyNames>();
                foreach (KeyValuePair<string, string> oKP in oDictionary)
                    oReturnList.Add(new KeyNames(oKP.Key, oKP.Value));
                return oReturnList;
            }
            catch (Exception)
            {
                return new List<KeyNames>();
            }
        }
        /// <summary>
        /// Gets Machine Stock Area list
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCodedMachineStockAreasList()
        {
            List<string> MachineStockAreas = new List<string>();
            foreach (KeyValuePair<string, string> oKP in Resource.MachineStockAreas)
                MachineStockAreas.Add(oKP.Value);
            return MachineStockAreas;
        }

        /// <summary>
        /// Gets status list for Delivery
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCodedStatusListForDelivery()
        {
            List<string> statusList = new List<string>();
            // statusList.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.OrderDeliveryStatusTypes)
                statusList.Add(oKP.Value);
            return statusList;
        }
        /// <summary>
        /// Get Coded Status list for invoice
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCodedStatusListForInvoice()
        {
            List<string> statusList = new List<string>();
            statusList.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.OrderInvoiceStatusTypes)
                statusList.Add(oKP.Value);
            return statusList;

        }
        /// <summary>
        /// List of Invoice Paid Status Types
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCodedStatusListForInvoicePaid()
        {
            List<string> statusList = new List<string>();
            statusList.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.InvoicePaidStatusTypes)
                statusList.Add(oKP.Value);
            return statusList;
        }
        /// <summary>
        /// List of Invoice Paid Status Types
        /// </summary>
        /// <returns></returns>
        public static List<string> GetInvoiceStatusListForFilter()
        {
            List<string> statusList = new List<string>();
            foreach (KeyValuePair<string, string> oKP in Resource.InvoicePaidStatusTypes)
                statusList.Add(oKP.Value);
            return statusList;
        }
        /// <summary>
        /// List of Invoice Paid Status Types
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCNStatusListForFilter()
        {
            List<string> statusList = new List<string>();
            foreach (KeyValuePair<string, string> oKP in Resource.CNStatusTypes)
                statusList.Add(oKP.Value);
            return statusList;
        }
        /// <summary>
        /// Bind All Creadit Limits 
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCreaditLimits()
        {
            List<string> CreaditList = new List<string>();
            CreaditList.Add(DDL_DEFAULT_VALUE);
            CreaditList.Add("0.00");
            CreaditList.Add("100.00");
            CreaditList.Add("250.00");
            CreaditList.Add("500.00");
            CreaditList.Add("1000.00");
            CreaditList.Add("2000.00");
            CreaditList.Add("3000.00");
            CreaditList.Add("4000.00");
            CreaditList.Add("5000.00");
            CreaditList.Add("6000.00");
            CreaditList.Add("7000.00");
            CreaditList.Add("8000.00");
            CreaditList.Add("9000.00");
            CreaditList.Add("10000.00");
            CreaditList.Add("15000.00");
            CreaditList.Add("20000.00");
            CreaditList.Add("25000.00");
            CreaditList.Add("30000.00");
            return CreaditList;
        }
        /// <summary>
        /// Get a list of Payment Terms
        /// </summary>
        /// <returns></returns>
        public static List<string> GetPaymentTerms()
        {
            List<string> oPaymentTerms = new List<string>();
            foreach (KeyValuePair<string, string> oKP in Resource.PaymentTerms)
                oPaymentTerms.Add(oKP.Value);
            return oPaymentTerms;
        }
        /// <summary>
        /// Get Coded payment Terms from list
        /// </summary>
        /// <param name="sPaymentTerm"></param>
        /// <returns></returns>
        public static string GetCodedPaymentTerms(string sPaymentTerm, bool IsNameRequired)
        {
            sPaymentTerm = sPaymentTerm.Trim();
            string sTerm = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.PaymentTerms)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == sPaymentTerm)
                        sTerm = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == sPaymentTerm)
                        sTerm = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sTerm))
                sTerm = Resource.DDL_DEFAULT_VALUE;
            return sTerm;
        }
        
             /// <summary>
        /// Get a list of Cut Off Payment Terms
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCutOffPaymentTerms()
        {
            List<string> oCutOffPaymentTerms = new List<string>();
            foreach (KeyValuePair<string, string> oKP in Resource.CutOffPaymentTerms)
                oCutOffPaymentTerms.Add(oKP.Value);
            return oCutOffPaymentTerms;
        }
        /// <summary>
        /// Get Coded Cut Off Payment Terms from list
        /// </summary>
        /// <param name="sPaymentTerm"></param>
        /// <returns></returns>
        public static string GetCodedCutOffPaymentTerms(string sCutOffPaymentTerm, bool IsNameRequired)
        {
            sCutOffPaymentTerm = sCutOffPaymentTerm.Trim();
            string sTerm = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.CutOffPaymentTerms)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == sCutOffPaymentTerm)
                        sTerm = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == sCutOffPaymentTerm)
                        sTerm = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sTerm))
                sTerm = Resource.DDL_DEFAULT_VALUE;
            return sTerm;
        }
        /// <summary>
        /// Get a list of Payment Terms
        /// </summary>
        /// <returns></returns>
        public static List<string> GetDeliveryMethod()
        {
            List<string> oDeliveryMethod = new List<string>();
            oDeliveryMethod.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.DeliveryMethod)
                oDeliveryMethod.Add(oKP.Value);
            return oDeliveryMethod;
        }
        /// <summary>
        /// Get Coded payment Terms from list
        /// </summary>
        /// <param name="sPaymentTerm"></param>
        /// <returns></returns>
        public static string GetCodedDeliveryMethods(string sMethod, bool IsNameRequired)
        {
            sMethod = sMethod.Trim();
            string sDeliveryMethod = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.DeliveryMethod)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == sMethod)
                        sDeliveryMethod = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == sMethod)
                        sDeliveryMethod = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sDeliveryMethod))
                sDeliveryMethod = Resource.DDL_DEFAULT_VALUE;
            return sDeliveryMethod;
        }
        /// <summary>
        /// Get All Coded Credit Limits
        /// </summary>
        /// <param name="CreditLimit"></param>
        /// <returns></returns>
        public static string GetCodedCreditLimit(string CreditLimit)
        {
            CreditLimit = CreditLimit.Trim();
            string sStatus = string.Empty;
            foreach (string CLimit in Resource.GetCreaditLimits())
            {
                if (CLimit.Trim().ToUpper() == CreditLimit.Trim().ToUpper())
                    sStatus = CLimit;
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_DEFAULT_VALUE;
            return sStatus;
        }
        /// <summary>
        /// Gets status list For Orders
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCodedStatusListForOrders()
        {
            List<string> statusList = new List<string>();
            statusList.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.OrderStatusTypes)
                statusList.Add(oKP.Value);
            return statusList;
        }
        /// <summary>
        /// Return Search Critiria List for Search DDL for Customer
        /// </summary>
        /// <returns></returns>
        public static List<string> GetSearchCriteriaListCustomer()
        {
            List<string> oListOfSearch = new List<string>();
            oListOfSearch.Add(DDL_DEFAULT_VALUE);
            oListOfSearch.Add(SEARCH_CUSTOMER_BY_NAME);
            oListOfSearch.Add(SEARCH_CUSTOMER_BY_ACCOUNT_NUMBER);
            return oListOfSearch;
        }
        /// <summary>
        /// Return Search Critiria List for Search DDL for Order
        /// </summary>
        /// <returns></returns>
        public static List<string> GetSearchCriteriaListOrder()
        {
            List<string> oListOfSearch = new List<string>();
            oListOfSearch.Add(DDL_DEFAULT_VALUE);
            oListOfSearch.Add(SEARCH_ORDER_BY_NUMBER);
            oListOfSearch.Add(SEARCH_ORDER_BY_CUSTOMER_NAME);
            return oListOfSearch;
        }
        public static List<string> GetProductCategoryValueList()
        {
            List<string> ProductCategoryList = new List<string>();
            ProductCategoryList.Add(DDL_DEFAULT_VALUE);

            foreach (KeyValuePair<string, string> oKP in Resource.ParentCategoryType)
                ProductCategoryList.Add(oKP.Value);
            return ProductCategoryList;
        }
        /// <summary>
        /// Gets permission list
        /// </summary>
        /// <returns></returns>
        public static List<string> GetCodedPermissionList()
        {
            List<string> permissionList = new List<string>();
            foreach (KeyValuePair<string, string> oKP in Resource.PermissionTypes)
                permissionList.Add(oKP.Value);
            return permissionList;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static List<string> GetPermissionListForSuperUser()
        {
            List<string> permissionList = new List<string>();
            foreach (KeyValuePair<string, string> oKP in Resource.PermissionTypes)
                permissionList.Add(oKP.Key);
            return permissionList;
        }

        /// <summary>
        /// Get Coded Status 
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedStatus(string StatusParam, bool IsNameRequired)
        {
            StatusParam = StatusParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.StatusTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == StatusParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == StatusParam)
                        sStatus = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_DEFAULT_VALUE;
            return sStatus;
        }
        /// <summary>
        /// Get Coded Machine Stock Area 
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedMachineStockArea(string AreaParam, bool IsNameRequired)
        {
            AreaParam = AreaParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.MachineStockAreas)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == AreaParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == AreaParam)
                        sStatus = oKVP.Key;
                }
            }
            return sStatus;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedStatusForOrder(string StatusParam, bool IsNameRequired)
        {
            StatusParam = StatusParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.OrderStatusTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == StatusParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == StatusParam)
                        sStatus = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_DEFAULT_VALUE;
            return sStatus;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedStatusForDelivery(string StatusParam, bool IsNameRequired)
        {
            StatusParam = StatusParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.OrderDeliveryStatusTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == StatusParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == StatusParam)
                        sStatus = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_ACTIVE_VALUE;
            return sStatus;
        }
        /// <summary>
        /// Get Coded Status For Invoice
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedStatusForInvoice(string StatusParam, bool IsNameRequired)
        {
            StatusParam = StatusParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.OrderInvoiceStatusTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == StatusParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == StatusParam)
                        sStatus = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_DEFAULT_VALUE;
            return sStatus;
        }
        /// <summary>
        /// get Coded Invoice Paid Status Types
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedStatusForInvoicePaid(string StatusParam, bool IsNameRequired)
        {
            StatusParam = StatusParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.InvoicePaidStatusTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == StatusParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == StatusParam)
                        sStatus = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_DEFAULT_VALUE;
            return sStatus;
        }

        /// <summary>
        /// get Coded Invoice Paid Status Types
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedStatusForCreditNotes(string StatusParam, bool IsNameRequired)
        {
            StatusParam = StatusParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.CNStatusTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == StatusParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == StatusParam)
                        sStatus = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_DEFAULT_VALUE;
            return sStatus;
        }

        /// <summary>
        /// GetLists For Active And Partial Order Status
        /// </summary>
        /// <returns></returns>
        public static List<string> GetNotDeliveredAndPartialDeliveredOrdersForDeliveries()
        {
            List<string> oStatusList = new List<string>();
            oStatusList.Add("ND");
            oStatusList.Add("PD");
            return oStatusList;
        }
        /// <summary>
        /// GetLists For Active And Partial Order Status For Invoice
        /// </summary>
        /// <returns></returns>
        public static List<string> GetNotInvoicedAndPartialInvoicedOrdersForInvoice()
        {
            List<string> oStatusList = new List<string>();
            oStatusList.Add("NI");
            oStatusList.Add("PI");
            return oStatusList;
        }
        /// <summary>
        /// Get Payment methods on recording delivery
        /// </summary>
        /// <returns></returns>
        public static List<string> GetPaymentTypes()
        {
            List<string> oPaymentTypes = new List<string>();
            oPaymentTypes.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.PaymentTypes)
                oPaymentTypes.Add(oKP.Value);
            return oPaymentTypes;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static List<string> GetPaymentMethodForOrder()
        {
            List<string> oPaymentMethods = new List<string>();
            oPaymentMethods.Add(DDL_DEFAULT_VALUE);
            foreach (KeyValuePair<string, string> oKP in Resource.PaymentMethodForOrder)
                oPaymentMethods.Add(oKP.Value);
            return oPaymentMethods;
        }

        /// <summary>
        /// Get codes for Payment Types
        /// </summary>
        /// <param name="sPriceParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedPaymentTypes(string sTypeParam, bool IsNameRequired)
        {
            sTypeParam = sTypeParam.Trim();
            string sType = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.PaymentTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == sTypeParam)
                        sType = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value.ToUpper() == sTypeParam.ToUpper())
                        sType = oKVP.Key;
                }
            }
            if (IsNameRequired)
            {
                if (string.IsNullOrEmpty(sType))
                {
                    sType = sTypeParam;
                }
            }
            return sType;
        }
        /// <summary>
        /// Get codes for Payment Types for order
        /// </summary>
        /// <param name="sPriceParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedPaymentMethodForOrder(string sTypeParam, bool IsNameRequired)
        {
            sTypeParam = sTypeParam.Trim();
            string sType = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.PaymentMethodForOrder)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == sTypeParam)
                        sType = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value.ToUpper() == sTypeParam.ToUpper())
                        sType = oKVP.Key;
                }
            }
            if (IsNameRequired)
            {
                if (string.IsNullOrEmpty(sType))
                {
                    sType = sTypeParam;
                }
            }
            return sType;
        }
        /// <summary>
        /// Get codes for Offer Price
        /// </summary>
        /// <param name="sPriceParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedPrice(string sPriceParam, bool IsNameRequired)
        {
            sPriceParam = sPriceParam.Trim();
            string sPrice = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.OfferPrices)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == sPriceParam)
                        sPrice = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value.ToUpper() == sPriceParam.ToUpper())
                        sPrice = oKVP.Key;
                }
            }
            if (IsNameRequired)
            {
                if (string.IsNullOrEmpty(sPrice))
                {
                    sPrice = sPriceParam;
                }
            }
            return sPrice;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetProductCategorySelectedValue(string StatusParam, bool IsNameRequired)
        {
            StatusParam = StatusParam.Trim();
            string sStatus = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.ParentCategoryType)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == StatusParam)
                        sStatus = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == StatusParam)
                        sStatus = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sStatus))
                sStatus = Resource.DDL_DEFAULT_VALUE;
            return sStatus;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="StatusParam"></param>
        /// <param name="IsNameRequired"></param>
        /// <returns></returns>
        public static string GetCodedPermission(string permissionParam, bool IsNameRequired)
        {
            permissionParam = permissionParam.Trim();
            string sPermission = string.Empty;
            foreach (KeyValuePair<string, string> oKVP in Resource.PermissionTypes)
            {
                if (IsNameRequired)
                {
                    if (oKVP.Key == permissionParam)
                        sPermission = oKVP.Value;
                }
                else
                {
                    if (oKVP.Value == permissionParam)
                        sPermission = oKVP.Key;
                }
            }
            if (string.IsNullOrEmpty(sPermission))
                sPermission = Resource.DDL_DEFAULT_VALUE;
            return sPermission;
        }

        public static String GenerateSHAPasswordHash(string sPassword)
        {
            SHA1 oSHA = new SHA1CryptoServiceProvider();
            byte[] plainTextBytes = Encoding.UTF8.GetBytes(sPassword);
            byte[] encypPassword = oSHA.ComputeHash(plainTextBytes);
            return Convert.ToBase64String(encypPassword);
        }
        /// <summary>
        /// Show selected words
        /// </summary>
        /// <param name="strText"></param>
        /// <param name="strTooltip"></param>
        /// <param name="iLength"></param>
        /// <returns></returns>
        public static string ShowSelectedWords(string strText, out string strTooltip, int iLength)
        {
            strTooltip = strText;
            if (strText.Length > iLength)
                strText = strText.Substring(0, iLength) + "...";
            return strText;
        }
        /// <summary>
        /// Creates a random string
        /// </summary>
        /// <param name="passwordLength"></param>
        /// <returns></returns>
        public static string CreateRandomString()
        {
            string allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789!@$?_-";
            char[] chars = new char[20];
            Random rd = new Random();
            for (int i = 0; i < 20; i++)
                chars[i] = allowedChars[rd.Next(0, allowedChars.Length)];
            //Create SHA Hash
            return GenerateSHAPasswordHash(new string(chars)).Replace("/", "Y").Replace("\\", "N").Replace("?", "V");
        }

        public static string CreateEmailBody(EmailType oType, string[] sParams)
        {

            return "";
        }

        /// <summary>
        /// Validate Input value
        /// </summary>
        /// <param name="sFieldName"></param>
        /// <param name="sValue"></param>
        /// <param name="sValueType"></param>
        /// <param name="sLength"></param>
        /// <param name="sErrorMessage"></param>
        /// <returns></returns>
        public static bool ValidateInput(string sFieldName, string sValue, ValueTypes sValueType, int sLength, bool bMandatory, out string sErrorMessage)
        {
            sErrorMessage = string.Empty;
            // Mandatory field check

            if (bMandatory)
            {
                if (!(sValue.Trim().Length > 0))
                {
                    sErrorMessage = sFieldName + Resource.ERROR_MANDATORY;
                    return false;
                }
            }
            // If slength is 0 then there is no limit on string length. 
            if (sLength > 0)
            {
                if (sValue.Trim().Length > sLength)
                {
                    sErrorMessage = sFieldName + Resource.ERROR_LENGTH + sLength + " characters.";
                    return false;
                }
            }

            // Check for numeric.

            if (sValueType == ValueTypes.Numeric)
            {
                if (!IsNumeric(sValue))
                {
                    sErrorMessage = sFieldName + Resource.ERROR_NUMERIC;
                    return false;
                }
            }

            else if (sValueType == ValueTypes.AlphaNumeric)
            {
                if (!IsAlphaNumeric(sValue))
                {
                    sErrorMessage = sFieldName + Resource.ERROR_ALPHA_NUMERIC;
                    return false;
                }
            }

            else if (sValueType == ValueTypes.Phone)
            {
                if (!IsUKPhoneNumber(sValue))
                {
                    sErrorMessage = Resource.ERROR_PHONE;
                    return false;
                }
            }
            else if (sValueType == ValueTypes.ZipCode)
            {
                if (!IsUKZIPCode(sValue))
                {
                    sErrorMessage = Resource.ERROR_ZIPCODE;
                    return false;
                }
            }
            else if (sValueType == ValueTypes.Email)
            {
                if (!string.IsNullOrEmpty(sValue))
                {
                    if (!IsValidEmail(sValue))
                    {
                        sErrorMessage = Resource.ERROR_EMAIL_FORMAT;
                        return false;
                    }
                }
            }
            else if (sValueType == ValueTypes.IPAddress)
            {
                if (!IsValidIP(sValue))
                {
                    sErrorMessage = Resource.ERROR_IP_ADDRESS;
                    return false;
                }
            }
            else if (sValueType == ValueTypes.Status)
            {
                if (sValue.Equals(Resource.DDL_DEFAULT_VALUE))
                {
                    sErrorMessage = Resource.ERROR_SELECT_VALUE + sFieldName;
                    return false;
                }
            }
            else if (sValueType == ValueTypes.Float)
            {
                if (!IsFloat(sValue))
                {
                    sErrorMessage = sFieldName + Resource.ERROR_NUMERIC;
                    return false;
                }
            }


            return true;
        }
        /// <summary>
        /// Validate Controls
        /// </summary>
        /// <param name="PageData"></param>
        /// <param name="sErrorMessage"></param>
        /// <returns></returns>

        /// 

        public static bool Validate(Dictionary<string, string> PageData, ref string sErrorMessage)
        {
            List<string> sPasswords = new List<string>();
            if (PageData.Count > 0)
            {
                foreach (KeyValuePair<string, string> oPair in PageData)
                {
                    string sFieldName = string.Empty;
                    string sFieldValue = oPair.Value;
                    string sFieldtype = string.Empty;
                    bool bMandatory = false;
                    string[] aFieldParams = oPair.Key.Split('_');
                    if (aFieldParams.Length >= 3)
                    {
                        sFieldtype = aFieldParams[1].ToUpper();
                        sFieldName = aFieldParams[2].Replace("SPACE", " ");
                    }

                    if (aFieldParams.Length > 3)
                    {
                        bMandatory = (aFieldParams[3].ToUpper().Equals("MY") ? true : false);
                    }
                    switch (sFieldtype)
                    {
                        case "TXT":
                            if (sFieldValue.Trim().Length == 0)
                            {
                                sErrorMessage = sFieldName + " cannot be empty";
                                return false;
                            }
                            break;

                        case "NUM":
                            int iValue;
                            if (!int.TryParse(sFieldValue.Trim(), out iValue))
                            {
                                sErrorMessage = sFieldName + " is not numeric";
                                return false;
                            }
                            break;
                        case "DBL":
                            double dValue;
                            if (bMandatory)
                            {
                                if (sFieldValue.Trim().Length == 0)
                                {
                                    sErrorMessage = sFieldName + " cannot be empty.";
                                    return false;
                                }
                            }
                            if (!double.TryParse(sFieldValue.Trim(), out dValue))
                            {
                                sErrorMessage = sFieldName + " is not correct.";
                                return false;
                            }
                            break;

                        case "DDL":

                            if (sFieldValue.Trim().ToUpper().Equals(DDL_DEFAULT_VALUE.ToUpper()))
                            {
                                sErrorMessage = "Please select a value from " + sFieldName;
                                return false;
                            }
                            break;
                        case "EML":
                            if (!string.IsNullOrEmpty(sFieldValue.Trim()))
                            {
                                if (!IsValidEmail(sFieldValue.Trim()))
                                {
                                    sErrorMessage = sFieldName + " is not in valid Email format.";
                                    return false;
                                }
                            }
                            break;

                        case "PWD":
                            sPasswords.Add(sFieldValue.Trim());
                            if (string.IsNullOrEmpty(sFieldValue.Trim()))
                            {
                                sErrorMessage = sFieldName + " cannot be empty.";
                                return false;
                            }
                            if (sFieldValue.Length < 4)
                            {
                                sErrorMessage = sFieldName + " minimum 4 characters required.";
                                return false;
                            }
                            if (sPasswords.Count == 2)
                            {
                                if (!sPasswords[0].Equals(sPasswords[1]))
                                {
                                    sErrorMessage = Resource.ERROR_PASSWORD_NO_MATCH;
                                    return false;
                                }
                            }
                            break;

                        ///Added to Validate
                        case "PDL":
                            if (sFieldValue.Trim().ToUpper().Equals(DDL_DEFAULT_VALUE.ToUpper()))
                            {
                            }
                            break;
                        case "PHN":
                            //if (string.IsNullOrEmpty(sFieldValue.Trim()))
                            //{
                            //    sErrorMessage = sFieldName + " cannot be empty.";
                            //    return false;
                            //}
                            //if (!IsUKPhoneNumber(sFieldValue.Trim()))
                            //{
                            //    sErrorMessage = sFieldName + " is not in valid Phone Number format.";
                            //    return false;
                            //}
                            break;
                        case "ZIP":
                            //if (string.IsNullOrEmpty(sFieldValue.Trim()))
                            //{
                            //    sErrorMessage = sFieldName + " cannot be empty.";
                            //    return false;
                            //}
                            //if (!IsUKZIPCode(sFieldValue.Trim()))
                            //{
                            //    sErrorMessage = sFieldName + " is not in valid Zip Code format.";
                            //    return false;
                            //}
                            break;
                        case "WEB":
                            if (!string.IsNullOrEmpty(sFieldValue.Trim()))
                            {
                                if (!IsValidUrl(sFieldValue.Trim()))
                                {
                                    sErrorMessage = sFieldName + " is not in valid URL format.";
                                    return false;
                                }
                            }
                            break;
                        case "DTE":
                            if (bMandatory)
                            {
                                if (sFieldValue.Trim().Length == 0)
                                {
                                    sErrorMessage = sFieldName + " cannot be empty.";
                                    return false;
                                }
                            }
                            try
                            {
                                //If has value then try to parse
                                if (sFieldValue.Trim().Length > 0)
                                {
                                    DateTime thisDate = new DateTime();
                                    if (!IsValidDate(sFieldValue.Trim(), ref thisDate))
                                    {
                                        sErrorMessage = sFieldName + " is not a valid date.";
                                        return false;
                                    }
                                }
                            }
                            catch
                            {
                                sErrorMessage = sFieldName + " is not a valid date.";
                                return false;
                            }
                            break;


                    }
                }
            }
            return true;
        }
        public static bool IsValidDate(string dateString, ref DateTime date)
        {
            try
            {
                if (dateString.Length == 10)
                {

                    string[] dateparts = dateString.Split(',', '/', '-');
                    if (dateparts.Length != 3)
                        return false;

                    int day = int.Parse(dateparts[0]);
                    int month = int.Parse(dateparts[1]);
                    int year = int.Parse(dateparts[2]);

                    if (day > 31)
                        return false;
                    if (month > 12)
                        return false;
                    if (year < 1900)
                        return false;

                    date = new DateTime(year, month, day);
                    return true;
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
        /// <summary>
        /// Validate Column Types values
        /// </summary>
        /// <param name="sColumnValue"></param>
        /// <param name="oColumnType"></param>
        /// <param name="oValue"></param>
        /// <returns></returns>
        public static bool ValidateColumnsValue(string sColumnValue, ColumnTypes oColumnType, out object oValue)
        {
            int iValue = 0;
            string sValue = string.Empty;
            decimal dValue = 0;
            bool bValue = false;
            try
            {
                switch (oColumnType)
                {
                    case ColumnTypes.Int:
                        if (int.TryParse(sColumnValue, out iValue))
                        {
                            oValue = (object)iValue;
                            return true;
                        }
                        break;
                    case ColumnTypes.String:
                        oValue = (object)sValue;
                        return true;
                        break;
                    case ColumnTypes.Decimal:
                        if (decimal.TryParse(sColumnValue, out dValue))
                        {
                            oValue = (object)dValue;
                            return true;
                        }
                        break;
                    case ColumnTypes.Bool:
                        if (bool.TryParse(sColumnValue, out bValue))
                        {
                            oValue = (object)bValue;
                            return true;
                        }
                        break;

                }
                oValue = sValue;
                return false;
            }
            catch (Exception ex)
            {
                oValue = sValue;
                return false;
            }
        }
        /// <summary>
        /// Read key from config file
        /// </summary>
        /// <returns></returns>
        public static string ReadValueFromConfigration(string sKey)
        {

            try
            {
                if (ConfigurationSettings.AppSettings[sKey] != null)
                {
                    string sValue = string.Empty;
                    string sReadKey = ConfigurationSettings.AppSettings[sKey].ToString();
                    if (!string.IsNullOrEmpty(sReadKey))
                    {
                        return sReadKey;
                    }
                    else
                    {
                        return string.Empty;
                    }
                }
                else
                {
                    return string.Empty;
                }
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }
        /// <summary>
        /// Calculation of Total Amount, VAT, Delivery Charge and Sub Total
        /// </summary>
        /// <param name="IsVATPercent">true for Do we need calculation based on VAT percentage , false if we just want to add vat amount</param>
        /// <param name="p_sOrderAmount">Total Order amount of Items  as Parameter</param>
        /// <param name="p_sDCharge">Delivery charge amount as Parameter</param>
        /// <param name="p_sVATPercent">VAT percent as parameter</param>
        /// <param name="sOrderAmount">Total Order amount of Items</param>
        /// <param name="sDChargeAmount">Delivery charge amount</param>
        /// <param name="sVATAmount">calculated VAT amount</param>
        /// <param name="sSubTotalAmount">Calculated Sub total</param>
        /// <param name="sGrandTotal">Calculated grand total</param>
        /// <returns></returns>       
        public static bool CalculateTotals(bool IsVATPercent, string p_sOrderAmount, string p_sDCharge, string p_sVAT, out string sOrderAmount, out string sDChargeAmount, out string sVATPercent, out string sVATAmount, out string sSubTotalAmount, out string sGrandTotal)
        {
            decimal dOrderAmount = 0;
            decimal dVATPercentage = 0;
            decimal dDeliveryChargeAmount = 0;
            decimal dVATAmount = 0;
            decimal dSubTotalAmount = 0;
            decimal dGrandTotalAmount = 0;
            try
            {
                //Order amount
                if (!string.IsNullOrEmpty(p_sOrderAmount))
                {
                    dOrderAmount = Convert.ToDecimal(p_sOrderAmount);
                }
                //delivery charge amount
                if (!string.IsNullOrEmpty(p_sDCharge))
                {
                    dDeliveryChargeAmount = Convert.ToDecimal(p_sDCharge);
                }
                dSubTotalAmount = dOrderAmount + dDeliveryChargeAmount;
                //vat amount
                if (!string.IsNullOrEmpty(p_sVAT))
                {
                    if (!decimal.TryParse(p_sVAT, out dVATPercentage))
                    {
                        dVATPercentage = 0;
                    }
                    if (IsVATPercent)
                    {
                        if (dVATPercentage > 0)
                        {
                            dVATAmount = (dSubTotalAmount * dVATPercentage / 100);
                        }
                        else
                        {
                            dVATAmount = 0;
                        }
                    }
                    else
                    {
                        dVATAmount = dVATPercentage;
                    }

                }
                dGrandTotalAmount = dSubTotalAmount + dVATAmount;
                //Return Totals as Current (two digits after decimal.
                sOrderAmount = string.Format("{0:0.00}", dOrderAmount);
                sSubTotalAmount = string.Format("{0:0.00}", dSubTotalAmount);
                sVATPercent = string.Format("{0:0.00}", dVATPercentage);
                sVATAmount = string.Format("{0:0.00}", dVATAmount);
                sDChargeAmount = string.Format("{0:0.00}", dDeliveryChargeAmount);
                sGrandTotal = string.Format("{0:0.00}", dGrandTotalAmount);
                return true;
            }
            catch (Exception)
            {
                sOrderAmount = string.Format("{0:0.00}", dOrderAmount);
                sSubTotalAmount = string.Format("{0:0.00}", dSubTotalAmount);
                sVATPercent = string.Format("{0:0.00}", dVATPercentage);
                sVATAmount = string.Format("{0:0.00}", dVATAmount);
                sDChargeAmount = string.Format("{0:0.00}", dDeliveryChargeAmount);
                sGrandTotal = string.Format("{0:0.00}", dGrandTotalAmount);
                return false;
            }
        }

    }

    public enum EmailType
    {
        UserRegistrationToAdmin = 1,
        UserRegistrationToUser = 2,
        ResetPassword = 3,
        Welcome = 4,
        AccountLocked = 5,
        CustomerHaveLessCreditLimit = 6,
        ThanksForOrder = 7,
        OrderUnderProcess = 8,
        GoodsDispatched = 9,
        OrderCancelled = 10,
        OrderDelivered = 11,
        CustomerRegistration = 12,
        OverDueInvoice = 13
    }

    public enum StatusTypes
    {
        D,
        A,
        IP
    }
    public enum PermissionTypes
    {
        R,
        M,
        D
    }

    public enum ValueTypes
    {
        AlphaNumeric,
        Numeric,
        Date,
        Email,
        Phone,
        String,
        ZipCode,
        IPAddress,
        Status,
        Float
    }
    public enum MessageType
    {
        Info,
        Success,
        Error
    }
    public enum ProductCategoryType
    {
        P,
        SC
    }
    public enum ColumnTypes
    {
        Int,
        Decimal,
        String,
        Bool
    }

    public enum CriteriaSearchType
    {
        StartsWith = 'S',
        EndsWith = 'E',
        Contains = 'C',
        Equals = 'Q',
        LessThan = 'L',
        GreaterThan = 'G',
        Between = 'B',
        In = 'I',
        NotIn = 'O',
        None = 'N'
    }

    public enum CriteriaDataType
    {
        Number = 'N',
        DateTime = 'D',
        String = 'S'

    }
    public enum CriteriaRelationWithSibling
    {
        And = 'A',
        Or = 'O',
        None = 'N'
    }
    public enum AmountType
    {
        AmountIn,
        AmountOut
    }
    /// <summary>
    /// Credit note creation types
    /// </summary>
    public enum CreditNoteType
    {
        Invoice = 0,
        Customer = 1
    }
    public class KeyNames
    {
        public KeyNames(string p_Key, string p_Name)
        {
            this.Key = p_Key;
            this.Name = p_Name;
        }
        string name = string.Empty;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        string key = string.Empty;

        public string Key
        {
            get { return key; }
            set { key = value; }
        }
        public static CriteriaSearchType GetStringCriteriaSearchType(string p_SearchType)
        {
            if (p_SearchType.Equals("Contains"))
            {
                return CriteriaSearchType.Contains;
            }
            else if (p_SearchType.Equals("Equals"))
            {
                return CriteriaSearchType.Equals;
            }
            else if (p_SearchType.Equals("Starts with"))
            {
                return CriteriaSearchType.StartsWith;
            }
            else if (p_SearchType.Equals("Ends with"))
            {
                return CriteriaSearchType.EndsWith;
            }
            else
            {
                return CriteriaSearchType.None;
            }
        }



    }

    public class Status
    {
        private string key = string.Empty;

        public string StatusKey
        {
            get { return key; }
            set { key = value; }
        }
        private string value = string.Empty;

        public string StatusValue
        {
            get { return this.value; }
            set { this.value = value; }
        }
    }


}
